package org.deltaset.samples.mvc.web;

import java.util.List;
import javax.inject.Inject;
import org.deltaset.desktop.AppItem;
import org.deltaset.desktop.TopMenuProvider;
import org.deltaset.samples.mvc.menu.TopMenuProviderImpl;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

/**
 *
 * @author dmakariev
 */
@Controller
@RequestMapping("/home")
public class HomeController {

    
    private final TopMenuProvider topMenuProvider;
    
    private final DesktopBean desktopBean;

    @Inject
    public HomeController(TopMenuProvider topMenuProvider, DesktopBean desktopBean) {
        this.topMenuProvider = topMenuProvider;
        this.desktopBean = desktopBean;
    }
    
    


    @RequestMapping(value = "/menu", method = RequestMethod.GET)
    public String showMenu(Model uiModel) {
        //addDateTimeFormatPatterns(uiModel);
        //uiModel.addAttribute("owner", Owner.findOwner(id));
        //uiModel.addAttribute("itemId", id);

        final List<AppItem> topMenu = topMenuProvider.loadTopMenu();
        uiModel.addAttribute("topMenu", topMenu);
        uiModel.addAttribute("desktop", desktopBean);
        return "home/menu";
    }
}
